How to change the working directory?

I have found the

currentDirectory()

function to get the current working directory. BUT how to set (or change) the current working directory?

(Must I always specify the absolute file path for a stream/file?)


thsturm - Tue May 25 05:28:48 EDT 2010

Re: How to change the working directory?
Mathias Mamsch - Tue May 25 06:19:23 EDT 2010

I think there is no perm to do that. The question is, how are you facing problems with the current path? Your script should not rely on the current path, when you store a file to a stream or something you can just prepend the path:
 

const string myPath = "C:\\My Current Dir\\"
 
fileName = "test.txt"
Stream x = read (myPath filename)

 


Do you into default value problems, maybe with a dialog box or something? The only thing I see to control the current path is to start the DOORS client using another current path. There is probably a more or less dark way to change it from DXL.

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: How to change the working directory?
KylePeters - Thu Mar 27 11:03:02 EDT 2014

Mathias Mamsch - Tue May 25 06:19:23 EDT 2010

I think there is no perm to do that. The question is, how are you facing problems with the current path? Your script should not rely on the current path, when you store a file to a stream or something you can just prepend the path:
 

const string myPath = "C:\\My Current Dir\\"
 
fileName = "test.txt"
Stream x = read (myPath filename)

 


Do you into default value problems, maybe with a dialog box or something? The only thing I see to control the current path is to start the DOORS client using another current path. There is probably a more or less dark way to change it from DXL.

Regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

This doesn't work if the code you are working in doesn't know what the path should be.  For instance, we have an *.inc file that reads a text-based configuration file in order to get details about modules the DXL script needs to run against.  Most of the ppl running this script can manage the text-based configuration file to get the data they need out of the script, but they are not versed in DXL.  The inc file and the text file are a pair; so the reference to the config file is a relative path within the *.inc file.  I don't control where our developers place these 2 files on their work PCs, so I can't specify an absolute path.

The script can calculate where the inc file resides, but I don't want to specify an absolute path within that inc file because the user could have placed the *.inc/*.txt file pair in any directory on their PC.  Is there a mechanism to specify an includes path [like you would in a makefile in programming] without forcing everyone on my entire team to change their DOORS command-line?

If there is no such solution, it might also work to have the *.inc file detect its own file location (not sure if that's possible) and then infer the location of the config file from the path the *.inc file is running from.

 

On a side note I have found that, if you use the Load File Selector from the Edit DXL dialog box to select a DXL file from some directory (X), then relative paths from within directory X work just fine [surprisingly, even when script was a layout DXL which wasn't even running from the Edit DXL dialog).  I had assumed this was because the Edit DXL Load File Selector was somehow setting the current working directory but it seems odd that a File Selector would have a capability that's not already somehow built into DXL.

Re: How to change the working directory?
llandale - Fri Mar 28 11:42:09 EDT 2014

KylePeters - Thu Mar 27 11:03:02 EDT 2014

This doesn't work if the code you are working in doesn't know what the path should be.  For instance, we have an *.inc file that reads a text-based configuration file in order to get details about modules the DXL script needs to run against.  Most of the ppl running this script can manage the text-based configuration file to get the data they need out of the script, but they are not versed in DXL.  The inc file and the text file are a pair; so the reference to the config file is a relative path within the *.inc file.  I don't control where our developers place these 2 files on their work PCs, so I can't specify an absolute path.

The script can calculate where the inc file resides, but I don't want to specify an absolute path within that inc file because the user could have placed the *.inc/*.txt file pair in any directory on their PC.  Is there a mechanism to specify an includes path [like you would in a makefile in programming] without forcing everyone on my entire team to change their DOORS command-line?

If there is no such solution, it might also work to have the *.inc file detect its own file location (not sure if that's possible) and then infer the location of the config file from the path the *.inc file is running from.

 

On a side note I have found that, if you use the Load File Selector from the Edit DXL dialog box to select a DXL file from some directory (X), then relative paths from within directory X work just fine [surprisingly, even when script was a layout DXL which wasn't even running from the Edit DXL dialog).  I had assumed this was because the Edit DXL Load File Selector was somehow setting the current working directory but it seems odd that a File Selector would have a capability that's not already somehow built into DXL.

This response may not actually help.

I asked Telelogic if an included include file could directly determine it's full path; but it could not.  However, although I never got around to it, you could do this

  • Have the include file get the DOORSADDINS environment variable when the include file is interpreted.
  • Parse the variable into it's separate paths (separated by semi-colons).
  • Looping through all the addins paths, look for the existance of the include file itself by concatenating the addins path with the include's relative path
  • Stop when you find the include file.

Before the explicit "addins" variable paths are searched, DOORS will automatically search these first (I think, need verification)

  1. Current Directory
  2. Instal Directory /lib/dxl

So:

  • If your "addins" variable is "c:/Doors-Stuff;//MyServer/Doors-Stuff"
  • If you include the include file with "IncludeFiles/MyIncludeFile.inc"

Then you would look for that Windows file, in a loop, here; stopping when found:

  1. getCurrentDirectory() "/IncludeFiles/MyIncludeFile.inc"
  2. C:\Program Files (x86)\IBM\Rational\DOORS\9.5\lib\dxl\IncludeFiles/MyIncludeFile.inc
  3. c:/Doors-Stuff/IncludeFiles/MyIncludeFile.inc
  4. //MyServer/Doors-Stuff/IncludeFiles/MyIncludeFile.inc

In your case you are looking for the data file.

Here is my function to see if a windows file actually exists; not sure it is "perfect".

  • //*********************
  • bool fIsFile(string in_NameFile)
  • { // Does the named windows file actually exist.
  •  // Name should be fully qualified
  •   // print ">>fIsFile " (!null in_NameFile and canOpenFile(in_NameFile, false)) "\t[" in_NameFile "]\n"
  •  return(!null in_NameFile and canOpenFile(in_NameFile, false))
  • } // end fIsFile()

-Louie

Having said all that, I did manage to somehow change the "currentDirectory" of the client PC when running DOORS on CITRIX, the client PC user would open Windows and navigate to some directory.  This was the only time the "currentDirectory" was not also the "InstallDirectory" that I found.  Never figured it out exactly, nor how to do it with a normal DOORS client.